package com.jz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by Hasee on 2022-03-07.
 */
@RestController
public class XiaoLongController {
    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("xiaolongfuwu")
    public UserVo add(HttpServletRequest request){
      //获取到登陆信息
        String loginInfo = "";
        Cookie[] cookies = request.getCookies();
        for(Cookie cookie : cookies){
            if(cookie.getName().equals("loginInfo")){
                loginInfo = cookie.getValue();

            }
        }
       UserVo userVo= (UserVo)redisTemplate.opsForValue().get(loginInfo);
        System.out.println();
        return userVo;
    }
}
